package com.xiyoufang.club.utils;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class ClubSessionMap extends ConcurrentHashMap {


    static final class Single {
        private final static ClubSessionMap SESSION_MAP = new ClubSessionMap();

        public static ClubSessionMap access$100() {
            return SESSION_MAP;
        }

    }

    private static ClubSessionMap clubSessionMap;

    private ClubSessionMap() {
        super(2000);
        if (clubSessionMap == null) {
            clubSessionMap = ClubSessionMap.Single.access$100();
        }

    }

    public static ClubSessionMap getInstance() {
        if (clubSessionMap == null) {
            clubSessionMap = ClubSessionMap.Single.access$100();
        }

        return clubSessionMap;
    }

    public static void addRoomId(int clubId, String roomId) {
        if (clubSessionMap == null) {
            clubSessionMap = ClubSessionMap.Single.access$100();
        }

        if (clubSessionMap.get(clubId) != null) {
            ((List) clubSessionMap.get(clubId)).add(roomId);
        } else {
            // clubSessionMap.put(clubId, new  (roomId));
        }

    }

    public static void removeRoomId(int clubId, String roomId) {
        if (clubSessionMap == null) {
            clubSessionMap = ClubSessionMap.Single.access$100();
        }

        if (clubSessionMap.get(clubId) != null) {
            ((List) clubSessionMap.get(clubId)).remove(roomId);
        }

    }


}
